import request from '@/utils/request'

export function selectPage(params) {
  return request({
    url: '/monitor/monitorPest/selectAllPage',
    method: 'post',
    data: params
  })
}

export function getCreators() {
  return request({
    url: '/monitor/monitorPest/getCreators',
    method: 'get'
  })
}

export function getProtective() {
  return request({
    url: '/monitor/monitorProtective/getProtective',
    method: 'get'
  })
}

export function getById(id) {
  return request({
    url: '/monitor/monitorPest/getById',
    method: 'get',
    params: { id }
  })
}

export function add(params) {
  return request({
    url: '/monitor/monitorPest/add',
    method: 'post',
    data: params
  })
}

export function update(params) {
  return request({
    url: '/monitor/monitorPest/update',
    method: 'post',
    data: params
  })
}

export function deleteById(id) {
  return request({
    url: '/monitor/monitorPest/delete',
    method: 'get',
    params: { id }
  })
}

export function upload(uploadFile, bucket, objectName) {
  const formData = new FormData();
  formData.append('uploadFile', uploadFile); // 对应后端 MultipartFile 参数名
  formData.append('bucket', bucket);
  formData.append('objectName', objectName);

  return request({
    url: '/oss/file/uploadImage',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}


